<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 150px;
            height: 150px;
            border: 1px solid black;
            margin: 20px;
        }

        .default {}

        .orange {
            background: orange;
        }

        .skyblue {
            background: skyblue;
        }
    </style>
</head>

<body>
    <div id="app">
        <h3>todo</h3>
        <!-- 按键修饰符 -->
        <input v-model="val" @keyUp.enter="addItem" type="text">

        <h3>正在进行</h3>
        <ul>
            <!-- v-for  v-if -->
            <li v-for="(item, index) in list" v-show="item.flag">
                <input v-model="item.flag" type="checkbox">
                {{ item.title }} --
                <button @click="delItem(index)">删除</button>
            </li>
        </ul>
        <h3>已经完成</h3>
        <ul>
            <!-- v-for  v-if -->
            <li v-for="(item, index) in list" v-show="!item.flag">
                <input v-model="item.flag" type="checkbox">
                {{ item.title }} --
                <button @click="delItem(index)">删除</button>
            </li>
        </ul>
    </div>


    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script>
        // enter  回车
        // .tab   Tab
        // .delete (捕获“删除”和“退格”键)
        // .esc   退出
        // .space 空格
        // .up
        // .down
        // .left
        // .right
        const app = new Vue({
            el: "#app",
            data: {
                // 输入内容
                val: "",
                list: []
            },
            methods: {
                addItem() {
                    this.list.push({
                        title: this.val,
                        flag: true
                    })
                    this.val = ""
                },
                delItem(index) {
                    this.list.splice(index, 1)
                }
            }
        })
    </script>

    正在进行中
    <list type="true"></list>
    已经完成
    <list type="false"></list>
</body>

</html>